﻿using System;
using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace KKCai.Utils.Web
{
    public class PageBase : Page
    {
        public string GetAppSetting(string key)
        {
            return ConfigHelper.GetAppSetting(key);
        }

        public string GetAppSetting(int index)
        {
            return ConfigHelper.GetAppSetting(index);
        }

        public string GetStringUrlParam(string key)
        {
            return UrlHelper.GetStringUrlParam(key);
        }
        public string GetStringUrlParam(string key, string defaultValue)
        {
            return UrlHelper.GetStringUrlParam(key, defaultValue);
        }

        public int GetIntUrlParam(string key)
        {
            return UrlHelper.GetIntUrlParam(key);
        }
        public int GetIntUrlParam(string key, int defaultValue)
        {
            return UrlHelper.GetIntUrlParam(key, defaultValue);
        }

        public static bool GetBoolUrlParam(string key)
        {
            return UrlHelper.GetBoolUrlParam(key);
        }
        public static bool GetBoolUrlParam(string key, bool defaultValue)
        {
            return UrlHelper.GetBoolUrlParam(key, defaultValue);
        }

        public static DateTime GetDateTimeUrlParam(string key)
        {
            return UrlHelper.GetDateTimeUrlParam(key);
        }
        public static DateTime GetDateTimeUrlParam(string key, DateTime defaultValue)
        {
            return UrlHelper.GetDateTimeUrlParam(key, defaultValue);
        }

        public void Alert(string message)
        {
            MsgBoxHelper.Alert(message);
        }

        public void Confirm(string message, string url)
        {
            MsgBoxHelper.Confirm(message, url);
        }

        public void Location(string url)
        {
            MsgBoxHelper.Location(url);
        }

        public void Location(string message, string url)
        {
            MsgBoxHelper.Location(message, url);
        }

        public void Close()
        {
            MsgBoxHelper.Close();
        }

        public void Close(string message)
        {
            MsgBoxHelper.Close(message);
        }

        public void GoBack()
        {
            MsgBoxHelper.GoBack();
        }

        public void GoBack(string message)
        {
            MsgBoxHelper.GoBack(message);
        }

        public string CutLen(object obj, int length)
        {
            if (obj == null)
                return string.Empty;

            return StringHelper.CutLen(obj.ToString(), length);
        }

        public void SaveCookie(string cookieName, string[] paramNames, string[] paramValues, DateTime expires)
        {
            CookieHelper.SaveCookie(cookieName, paramNames, paramValues, expires);
        }

        public void SaveCookie(string cookieName, string paramName, string paramValue, DateTime expires)
        {
            CookieHelper.SaveCookie(cookieName, paramName, paramValue, expires);
        }

        public void ClearCookie(string cookieName)
        {
            CookieHelper.ClearCookie(cookieName);
        }

        public int GetIntFormParam(string key)
        {
            return FormHelper.GetIntFormParam(key);
        }
        public int GetIntFormParam(string key, int def)
        {
            return FormHelper.GetIntFormParam(key, def);
        }

        public string GetStringFormParam(string key)
        {
            return FormHelper.GetStringFormParam(key);
        }
        public string GetStringFormParam(string key, string def)
        {
            return FormHelper.GetStringFormParam(key, def);
        }

        public static bool GetBoolFormParam(string key)
        {
            return FormHelper.GetBoolFormParam(key);
        }
        public static bool GetBoolFormParam(string key, bool defaultValue)
        {
            return FormHelper.GetBoolFormParam(key, defaultValue);
        }

        public DateTime GetDateTimeFormParam(string key)
        {
            return FormHelper.GetDateTimeFormParam(key);
        }
        public DateTime GetDateTimeFormParam(string key, DateTime def)
        {
            return FormHelper.GetDateTimeFormParam(key, def);
        }
        
    }
}
